|
|
|
|
|
|
|
The POINT structure should be declared in Visual Basic as follows: |
|
|
|
|
|
|
|
|
Type POINTAPI
x As Long
y As Long
End Type |
|
|
|
|
|
|
|
|
Why is the name changed to POINTAPI from POINT? Because ''point" is a Visual Basic reserved word, and replacing it with a user-defined structure can lead to confusion both on the part of people trying to understand your program and on the part of Visual Basic itself. |
|
|
|
|
|
|
|
|
The Polyline program is designed to divide a circle into a specified number of points and draw lines following a random path between all of the points on the circle as shown in Figure P7-1. |
|
|
|
|
|
|
|
|
The program has a text box that allows you to specify the number of points, a Clear button that allows you to clear the form, a Draw Shape button that allows you to perform the drawing operation, and an Auto checkbox that causes the program to continuously select a random number of points and draw the line sequence based on those points. The result can be some almost-hypnotic special effects. |
|
|
|
|
|
|
|
|
The example below shows the Polyline program. The SetupPoints function may be tricky to follow if you don't remember high school trigonometry. You don't really need to follow the mathematics behind the drawing to understand or |
|
|
|
|
|
|
|
|
Figure P7-1:
The Polyline program draws a random path of lines
between points on a circle |
|
|
|
|
|
|
|
|
Figure P7-2:
Illustration of the circle calculation |
|
|
|
|
|